<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>JavaScript 字符串模板</title>
</head>
<body>

<h2>JavaScript 模板字面量</h2>

<p>模板字面量允许字符串中的变量：</p>

<p id="demo"></p>

<script>
  let header = "Templates Literals";
  let tags = ["template literals", "javascript", "es6"];

  let html = `<h2>${header}</h2><ul>`;

  for (const x of tags) {
    html += `<li>${x}</li>`;
  }

  html += `</ul>`;
  document.getElementById("demo").innerHTML = html;
</script>


</body>
</html>